﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace assignment5
{
    public class OrderDetails
    {
        private Order order {  get; set; }
        private DateTime _date;
        private List<(int,int,string)> goods {  get; set; }
        private int total {  get; set; }

        public OrderDetails(Order order, DateTime time,List<(int,int,string)> goods) 
        { 
            this.order = order;
            this._date = time;
            this.goods = goods;
            foreach (var item in goods)
            {
                total += item.Item1 * item.Item2;
            }
        }
        public  int Total { get { return total; } }
        public int Getid { get { return order.Get; } }
        public override string ToString()
        {
            return order + "\n下单时间：" + _date.ToString() + "\n购物明细：" + string.Join(", ", goods.Select(item =>
            $"(price:{item.Item1}, counts:{item.Item2},goodsname:{item.Item3})")) + "\nin total:" + total;
        }
        public bool Equals(object obj)
        {
            OrderDetails other = obj as OrderDetails;
            return other != null && this.order.Equals(other) &&other._date == this._date
                &&other.goods == this.goods;
        }

    }
}
